// 登录模块
import { makeAutoObservable } from "mobx"
import { http,getToken,setToken } from '../utils'

class LoginStore {
  token = getToken || ''
  constructor() {
    makeAutoObservable(this)
  }
  // 登录
  login = async ({ userName, password }) => {
    const res = await http.post('/admin/login', {
      userName,
      password
    })
    console.log(res)
    //存入token
    this.token = res.data.data.token
    //存入ls
    setToken(this.token)
  }
}
export default LoginStore